import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:yj_health_plugin/yj_health_plugin.dart';
import 'package:yj_health_plugin_example/ios_sdk_client.dart';
import 'package:yj_health_plugin_example/ios_sdk_delegate.dart';
import 'package:yj_health_plugin_example/ios_sdk_utils.dart';

// flutter to ios
enum YJSyncDataType {
  ///0链接蓝牙设备
  yjSyncDataTypeConnect,
  ///1断开蓝牙
  yjSyncDataTypeDisconnect,
  ///2步数
  yjSyncDataTypeStep,
  ///3睡眠
  yjSyncDataTypeSleep,
  ///4心率
  yjSyncDataTypeHRM,
  ///5血压
  yjSyncDataTypeBlood,
  ///6血氧
  yjSyncDataTypeSaO2,
  ///7体温
  yjSyncDataTypeBodyTemperature,
}

// flutter to ios
enum YJUTECallBackType {
  ///0时间
  yjUTECallBackTypeTime,
  ///1电量
  yjUTECallBackTypeBattery,
  ///2设备信息
  yjUTECallBackTypeDeviceInfo,
  ///3久坐
  yjUTECallBackTypeLongSit,
  ///4关闭久坐
  yjUTECallBackTypeLongSitClose,
  ///5设置天气
  yjUTECallBackTypeLongSetWeather,
  ///6勿扰
  yjUTECallBackTypeDotDisturbMode,
  ///7打电话
  yjUTECallBackTypeTel,
  ///8设置语言
  yjUTECallBackTypeLanguage,
  ///9设置闹钟
  yjUTECallBackTypeAlarm,
}

// flutter to ios
enum YJCustomType {
  ///0initSdk,
  yjCustomTypeInitSdk,
  ///1搜索蓝牙
  yjCustomTypeScan,
  ///2停止搜索
  yjCustomTypeStop,
  ///3查找手机
  yjCustomTypeFindPhone,
  ///4音乐播放
  yjCustomTypeMusicPlay,
  ///5音乐上一首
  yjCustomTypeMusicLast,
  ///6音乐下一首
  yjCustomTypeMusicNext,
  ///7设置单位
  yjCustomTypeDeviceUnit,
}
/// SDK uteManagerDevicesSate方法
const yjSyncDataTypeName = 'yjSyncDataTypeName';
/// SDK uteManageUTEOptionCallBack方法
const yjUTECallBackTypeName = 'yjUTECallBackTypeName';
/// 自定义
const yjCustomTypeName = 'yjCustomTypeName';

/// 下面是动态化调用SDK里面的方法 归属于Other类
///################################OTHER################################################ 4.0新增API
/// ios SDK delegate 透传给 flutter ##iOS->flutter##
const yjSDKDelegateTypeName = 'yjSDKDelegateTypeName';
/// flutter to ios 映射 iOS SDK client action   flutter 透传给 ios SDK client  ##flutter->iOS##
/// 使用方式见最后的测试代码
const yjSDKClientTypeName = 'yjSDKClientTypeName';
///################################################################################


void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  void initState() {
    super.initState();
    YjHealthPlugin.instance.messageCallback = ((String message) {
      print("原生发送flutter消息--start");
      var jsonStr = message;
      Map<String, dynamic> arguments = json.decode(jsonStr);
      print("监听数据收到了");
      if (arguments.isNotEmpty) {
        print(arguments);
        print("我收到了消息");
        String name = arguments["name"];
        int tag = int.parse(arguments["tag"]);
        Map<String, dynamic> data = arguments["data"];
        if (name == yjSyncDataTypeName) {
          YJSDKUTEDevicesSate type = YJSDKUTEDevicesSate.values[tag];
          if (type == YJSDKUTEDevicesSate.yjUTEDevicesSateConnected) {
            print("蓝牙链接成功了---------------");
            print("开始SDK配置默认配置");
            Future.delayed(const Duration(seconds: 1)).then((onValue) {
              ///1.设置设备信息
              YjHealthPlugin.instance.flutterSendEvent(
                  flutterActionModel: FlutterActionModel(
                      type: FlutterActionType.sendData,
                      params: {
                        "name": yjUTECallBackTypeName,
                        "tag": YJUTECallBackType.yjUTECallBackTypeDeviceInfo.index,
                        "arguments": {
                          "heigh": 170,
                          "heighCM": 170,
                          "weight": 60,
                          "age": 18,
                          "sex": 2,
                          "lightTime": 6,
                          "sportTarget": 30000, //目标步数
                          "handlight": 1, //抬手亮屏
                        },
                      }));
              print("///1.设置设备信息");
            });
            Future.delayed(const Duration(seconds: 2)).then((onValue) {
              ///2.设置久坐提醒
              YjHealthPlugin.instance.flutterSendEvent(
                  flutterActionModel: FlutterActionModel(
                      type: FlutterActionType.sendData,
                      params: {
                        "name": yjUTECallBackTypeName,
                        "tag": YJUTECallBackType.yjUTECallBackTypeLongSit.index,
                        "arguments": {"time": 60},
                      }));
              print("///2.设置久坐提醒");
            });
            Future.delayed(const Duration(seconds: 3)).then((onValue) {
              ///3.设置勿扰时间
              YjHealthPlugin.instance.flutterSendEvent(
                  flutterActionModel: FlutterActionModel(
                      type: FlutterActionType.sendData,
                      params: {
                        "name": yjUTECallBackTypeName,
                        "tag":
                        YJUTECallBackType.yjUTECallBackTypeDotDisturbMode.index,
                        "arguments": {"startTime": "20:00", "endTime": "08:00"},
                      }));
              print("///3.设置勿扰时间");
              print("开始SDK配置默认配置结束-------end");
            });
          } else if (type == YJSDKUTEDevicesSate.yjUTEDevicesSateDisconnected) {
            print("蓝牙断开了---------------");
          } else {
            if (data["list"] != null && data["list"].isNotEmpty) {
              for (int i = 0; i < data["list"].length; i++) {
                Map<String, dynamic> info =
                    data["list"][i] as Map<String, dynamic>;
                if (info.isNotEmpty) {
                  if (type == YJSDKUTEDevicesSate.yjUTEDevicesSateSyncSuccess) {
                    if (info[kUTEQuerySportWalkRunData] != null &&
                        (info[kUTEQuerySportWalkRunData]).isNotEmpty) {
                      List<dynamic> listInfo = info[kUTEQuerySportWalkRunData];
                      print("同步步数------------------");
                      print(listInfo.toString());
                      print("同步步数------------------end");
                    } else if (info[kUTEQuery24HRMData] != null &&
                        (info[kUTEQuery24HRMData]).isNotEmpty) {
                      List<dynamic> listInfo = info[kUTEQuery24HRMData];
                      print("同步心率------------------");
                      print(listInfo.toString());
                      print("同步心率------------------end");
                    } else if (info[kUTEQuerySleepDataDayByDay] != null &&
                        (info[kUTEQuerySleepDataDayByDay]).isNotEmpty) {
                      List<dynamic> listInfo = info[kUTEQuerySleepDataDayByDay];
                      print("同步睡眠------------------");
                      print(listInfo.toString());
                      print("同步睡眠------------------end");
                    } else if (info[kUTEQuerySleepData] != null &&
                        (info[kUTEQuerySleepData]).isNotEmpty) {
                      List<dynamic> listInfo = info[kUTEQuerySleepData];
                      print("同步所有睡眠------------------");
                      print(listInfo.toString());
                      print("同步所有睡眠------------------end");
                    } else if (info[kUTEQueryBloodData] != null &&
                        (info[kUTEQueryBloodData]).isNotEmpty) {
                      List<dynamic> listInfo = info[kUTEQueryBloodData];
                      print("同步血压------------------");
                      print(listInfo.toString());
                      print("同步血压------------------end");
                    } else if (info[kUTEQueryBloodOxygenData] != null &&
                        (info[kUTEQueryBloodOxygenData]).isNotEmpty) {
                      List<dynamic> listInfo = info[kUTEQueryBloodOxygenData];
                      print("同步血氧------------------");
                      print(listInfo.toString());
                      print("同步血氧------------------end");
                    } else if (info[kUTEQueryBodyTemperature] != null &&
                        (info[kUTEQueryBodyTemperature]).isNotEmpty) {
                      List<dynamic> listInfo = info[kUTEQueryBodyTemperature];
                      print("同步体温------------------");
                      print(listInfo.toString());
                      print("同步体温------------------end");
                    }
                  } else if (type ==
                          YJSDKUTEDevicesSate
                              .yjUTEDevicesSateHeartCurrentValue ||
                      type ==
                          YJSDKUTEDevicesSate.yjUTEDevicesSateBodyTempNormal ||
                      type ==
                          YJSDKUTEDevicesSate
                              .yjUTEDevicesSateHeartDetectingProcess ||
                      type ==
                          YJSDKUTEDevicesSate
                              .yjUTEDevicesSateBloodDetectingProcess ||
                      type ==
                          YJSDKUTEDevicesSate
                              .yjUTEDevicesSateBloodOxygenDetectingProcess) {
                    if (info[kUTEQueryHRMData] != null &&
                        (info[kUTEQueryHRMData]).isNotEmpty) {
                      List<dynamic> listInfo = info[kUTEQueryHRMData];
                      print("实时心率------------------");
                      print(listInfo.toString());
                      print("实时心率------------------end");
                    } else if (info[kUTEQueryBodyTemperature] != null &&
                        (info[kUTEQueryBodyTemperature]).isNotEmpty) {
                      List<dynamic> listInfo = info[kUTEQueryBodyTemperature];
                      print("实时体温------------------");
                      print(listInfo.toString());
                      print("实时体温------------------end");
                    } else if (info[kUTEQueryBloodData] != null &&
                        (info[kUTEQueryBloodData]).isNotEmpty) {
                      List<dynamic> listInfo = info[kUTEQueryBloodData];
                      print("实时血压------------------");
                      print(listInfo.toString());
                      print("实时血压------------------end");
                    } else if (info[kUTEQueryBloodOxygenData] != null &&
                        (info[kUTEQueryBloodOxygenData]).isNotEmpty) {
                      List<dynamic> listInfo = info[kUTEQueryBloodOxygenData];
                      print("实时血氧------------------");
                      print(listInfo.toString());
                      print("实时血氧------------------end");
                    }
                  }
                }
              }
            }
          }
        } else if (name == yjUTECallBackTypeName) {
          YJSDKUTECallBack type = YJSDKUTECallBack.values[tag];
          if (type == YJSDKUTECallBack.yjUTECallBackSyncTime) {
            print("同步时间完成----end");
          } else if (type == YJSDKUTECallBack.yjUTECallBackDeviceBattery) {
            print("获取电量----");
            int battery = data["battery"];
            print(battery);
            print("获取电量----end");
          } else if (type == YJSDKUTECallBack.yjUTECallBackInfoHeightWeight) {
            print("设置用户信息完成----end");
          } else if (type == YJSDKUTECallBack.yjUTECallBackOpenUnitSitRemind) {
            print("设置久坐完成----end");
          } else if (type == YJSDKUTECallBack.yjUTECallBackCloseSitRemind) {
            print("关闭了久坐完成----end");
          } else if (type == YJSDKUTECallBack.yjUTECallBackWeatherSevenDay) {
            print("设置天气完成----end");
          } else if (type == YJSDKUTECallBack.yjUTECallBackDeviceSilence) {
            print("设置勿扰完成----end");
          } else if (type == YJSDKUTECallBack.yjUTECallBackOpenRemindMore) {
            print("设置电话消息完成----end");
          } else if (type == YJSDKUTECallBack.yjUTECallBackMultiLanguage) {
            print("设置语言完成----end");
          } else if (type == YJSDKUTECallBack.yjUTECallBackAlarm) {
            print("设置闹钟完成----end");
          } else if (type == YJSDKUTECallBack.yjUTECallBackOpen24HourHRM) {
            print("打开了24小时心率检测---end");
          } else if (type == YJSDKUTECallBack.yjUTECallBackClose24HourHRM) {
            print("关闭了24小时心率检测---end");
          } else if (type == YJSDKUTECallBack.yjUTECallBackBodyTemperatureSetTestDuration) {
            print("自动测量体温返回事件");
          } else if (type == YJSDKUTECallBack.yjUTECallBackBodyTemperatureSetAlarm) {
            print("测量体温报警设置返回事件");
          }
        } else if (name == yjCustomTypeName) {
          YJCustomType type = YJCustomType.values[tag];
          if (type == YJCustomType.yjCustomTypeInitSdk) {
            print("初始化SDK完成");
          } else if (type == YJCustomType.yjCustomTypeScan) {
            print("搜索蓝牙完成");
          } else if (type == YJCustomType.yjCustomTypeStop) {
            print("停止了搜索蓝牙完成");
          } else if (type == YJCustomType.yjCustomTypeFindPhone) {
            print("手表触发了查找手机按钮");
          } else if (type == YJCustomType.yjCustomTypeMusicPlay) {
            print("手表触发了音乐播放按钮");
          } else if (type == YJCustomType.yjCustomTypeMusicLast) {
            print("手表触发了音乐播放上一首按钮");
          } else if (type == YJCustomType.yjCustomTypeMusicNext) {
            print("手表触发了音乐播放下一首按钮");
          }
        } else if (name == yjSDKDelegateTypeName) {
          YJSDKDelegateType type = YJSDKDelegateType.values[tag];
          print("##############################");
          print(type);
          print("获取了type");
          print("##############################end");
          if (type ==
              YJSDKDelegateType.yjSDKDelegateTypeUteManagerExtraIsAble) {
            print("是否点击了弹框按钮权限");
          }
        }
      }
      print("原生发送flutter消息--end");
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: ListView(
          children: [
            const Text("------------------------------------"),
            const Text("-------------$yjCustomTypeName------------------"),
            Column(
              children: YJCustomType.values.map((type) {
                return InkWell(
                  onTap: () async {
                    Map<String, dynamic> arguments = {};
                    if (type == YJCustomType.yjCustomTypeDeviceUnit) {
                      arguments = {
                        "unit": 1, //0 UTEOptionUnitInch    1 UTEOptionUnitMeter
                      };
                    }
                    await YjHealthPlugin.instance.flutterSendEvent(
                        flutterActionModel: FlutterActionModel(
                            type: FlutterActionType.sendData,
                            params: {
                          "name": yjCustomTypeName,
                          "tag": type.index.toString(),
                          "arguments": arguments,
                        }));
                  },
                  child: ListTile(
                    title: Text("${type.name}${type.index}"),
                  ),
                );
              }).toList(),
            ),

            const Text("------------------------------------"),
            const Text("-------------$yjSyncDataTypeName------------------"),
            Column(
              children: YJSyncDataType.values.map((type) {
                return InkWell(
                  onTap: () async {
                    Map<String, dynamic> arguments = {};
                    if (type == YJSyncDataType.yjSyncDataTypeBodyTemperature) {
                      arguments = {"startTime": "2022-10-12-09-30"};
                    } else if (type == YJSyncDataType.yjSyncDataTypeConnect) {
                      arguments = {
                        "address": "AE390EC1-FFF4-6B30-5EA9-68F666C278EC"
                      };

                      ///iphone12 caofuqing
                    }
                    await YjHealthPlugin.instance.flutterSendEvent(
                        flutterActionModel: FlutterActionModel(
                            type: FlutterActionType.sendData,
                            params: {
                          "name": yjSyncDataTypeName,
                          "tag": type.index.toString(),
                          "arguments": arguments,
                        }));
                  },
                  child: ListTile(
                    title: Text("${type.name}${type.index}"),
                  ),
                );
              }).toList(),
            ),

            const Text("------------------------------------"),
            const Text("-------------$yjUTECallBackTypeName------------------"),
            Column(
              children: YJUTECallBackType.values.map((type) {
                return InkWell(
                  onTap: () async {
                    Map<String, dynamic> arguments = {};
                    if (type == YJUTECallBackType.yjUTECallBackTypeLongSit) {
                      arguments = {"time": 60};

                      ///久坐 区间在   <10,180>
                    } else if (type ==
                        YJUTECallBackType.yjUTECallBackTypeLongSetWeather) {
                      arguments = {
                        "list": [
                          //设置近7天天气 （第一个元素代表今天）
                          {
                            "type": 1,
                            "city": "上海",
                            "temperatureCurrent": 10,
                            "temperatureMax": 25,
                            "temperatureMin": 2
                          },
                          {
                            "type": 1,
                            "city": "上海",
                            "temperatureCurrent": 5,
                            "temperatureMax": 25,
                            "temperatureMin": 2
                          },
                          {
                            "type": 1,
                            "city": "上海",
                            "temperatureCurrent": 5,
                            "temperatureMax": 25,
                            "temperatureMin": 2
                          },
                          {
                            "type": 1,
                            "city": "上海",
                            "temperatureCurrent": 5,
                            "temperatureMax": 25,
                            "temperatureMin": 2
                          },
                          {
                            "type": 1,
                            "city": "上海",
                            "temperatureCurrent": 5,
                            "temperatureMax": 25,
                            "temperatureMin": 2
                          },
                          {
                            "type": 1,
                            "city": "上海",
                            "temperatureCurrent": 5,
                            "temperatureMax": 25,
                            "temperatureMin": 2
                          },
                          {
                            "type": 1,
                            "city": "上海",
                            "temperatureCurrent": 5,
                            "temperatureMax": 25,
                            "temperatureMin": 2
                          },
                        ]
                      };
                    } else if (type ==
                        YJUTECallBackType.yjUTECallBackTypeDotDisturbMode) {
                      arguments = {"startTime": "23:00", "endTime": "08:00"};
                    } else if (type ==
                        YJUTECallBackType.yjUTECallBackTypeDeviceInfo) {
                      arguments = {
                        "heigh": 170,
                        "heighCM": 170,
                        "weight": 60,
                        "age": 18,
                        "sex": 2,
                        "lightTime": 6,
                        "sportTarget": 8000,
                        "handlight": 1,
                      };
                    } else if (type ==
                        YJUTECallBackType.yjUTECallBackTypeAlarm) {
                      arguments = {
                        "list": [
                          //设置闹钟1
                          {
                            "time": "10:28",
                            "week": YJSDKUTEAlarmWeek
                                    .yjSDKUTEAlarmWeekMonday.value |
                                YJSDKUTEAlarmWeek
                                    .yjSDKUTEAlarmWeekTuesday.value |
                                YJSDKUTEAlarmWeek
                                    .yjSDKUTEAlarmWeekWednesday.value |
                                YJSDKUTEAlarmWeek
                                    .yjSDKUTEAlarmWeekThursday.value |
                                YJSDKUTEAlarmWeek
                                    .yjSDKUTEAlarmWeekFriday.value |
                                YJSDKUTEAlarmWeek
                                    .yjSDKUTEAlarmWeekSaturday.value |
                                YJSDKUTEAlarmWeek.yjSDKUTEAlarmWeekSunday.value,
                            "enable": true,
                            "num": 1,
                            "countVibrate": 5
                          },
                          //设置闹钟2
                          {
                            "time": "10:34",
                            "week": YJSDKUTEAlarmWeek
                                    .yjSDKUTEAlarmWeekMonday.value |
                                YJSDKUTEAlarmWeek
                                    .yjSDKUTEAlarmWeekTuesday.value |
                                YJSDKUTEAlarmWeek
                                    .yjSDKUTEAlarmWeekWednesday.value |
                                YJSDKUTEAlarmWeek
                                    .yjSDKUTEAlarmWeekThursday.value |
                                YJSDKUTEAlarmWeek
                                    .yjSDKUTEAlarmWeekFriday.value |
                                YJSDKUTEAlarmWeek
                                    .yjSDKUTEAlarmWeekSaturday.value |
                                YJSDKUTEAlarmWeek.yjSDKUTEAlarmWeekSunday.value,
                            "enable": true,
                            "num": 2,
                            "countVibrate": 5
                          },
                          //设置闹钟3
                          {
                            "time": "10:35",
                            "week": YJSDKUTEAlarmWeek
                                    .yjSDKUTEAlarmWeekMonday.value |
                                YJSDKUTEAlarmWeek
                                    .yjSDKUTEAlarmWeekTuesday.value |
                                YJSDKUTEAlarmWeek
                                    .yjSDKUTEAlarmWeekWednesday.value |
                                YJSDKUTEAlarmWeek
                                    .yjSDKUTEAlarmWeekThursday.value |
                                YJSDKUTEAlarmWeek
                                    .yjSDKUTEAlarmWeekFriday.value |
                                YJSDKUTEAlarmWeek
                                    .yjSDKUTEAlarmWeekSaturday.value |
                                YJSDKUTEAlarmWeek.yjSDKUTEAlarmWeekSunday.value,
                            "enable": true,
                            "num": 3,
                            "countVibrate": 5
                          },
                        ]
                      };
                    }
                    await YjHealthPlugin.instance.flutterSendEvent(
                        flutterActionModel: FlutterActionModel(
                            type: FlutterActionType.sendData,
                            params: {
                          "name": yjUTECallBackTypeName,
                          "tag": type.index.toString(),
                          "arguments": arguments,
                        }));
                  },
                  child: ListTile(
                    title: Text("${type.name}${type.index}"),
                  ),
                );
              }).toList(),
            ),

            /// 适配iOS 所有flutter to ios 方法  可选择性使用
            const Text("------------------------------------"),
            const Text("-------------$yjSDKClientTypeName------------------"),
            Column(
              children: YJSDKClientType.values.map((type) {
                Map<String, dynamic> arguments = {
                  "list": [
                    // 默认没有参数 空的数组
                  ]
                };
                if (type == YJSDKClientType.connectUTEModelDevices_) {
                  /// 自定义模式  连接设备蓝牙
                  arguments = {
                    "list": [
                      // 自定义操作  要传递type  根据内部操作逻辑
                      {"address": "AE390EC1-FFF4-6B30-5EA9-68F666C278EC"}

                      ///iphone12 caofuqing
                    ]
                  };
                } else if (type == YJSDKClientType.setUTEInfoModel_) {
                  /// 设置用户信息
                  arguments = {
                    "list": [
                      // 第一个对象是model类型
                      {
                        YJSDKClientParameterType
                            .yjSDKClientParameterTypeModel.name: {
                          YJSDKClientParameterUTEModelDeviceInfo: {
                            "heigh": 170,
                            "heighCM": 170,
                            "weight": 60,
                            "age": 18,
                            "sex": 2,
                            "lightTime": 6,
                            "sportTarget": 8000,
                            "handlight": 1,
                          }
                        },
                      }
                    ]
                  };
                } else if (type == YJSDKClientType.syncDataGPS_) {
                  /// 同步GPS
                  arguments = {
                    "list": [
                      // 第一个对象是String类型
                      {
                        "time": "2022-10-12-09-30",
                      }
                    ]
                  };
                } else if (type == YJSDKClientType.getUTEWeatherType_) {
                  /// 设置部分设备信息
                  arguments = {
                    "list": [
                      // 第一个对象是枚举类型
                      {
                        "weatherCode": 302,/// 雷阵雨
                      }
                    ]
                  };
                } else if (type == YJSDKClientType.sendUTESevenWeather_) {
                  /// 设置7天天气
                  arguments = {
                    "list": [
                      // 第一个对象是model类型
                      {
                        YJSDKClientParameterType
                            .yjSDKClientParameterTypeArrayModel.name: {
                          YJSDKClientParameterUTEModelWeather: [
                            //设置近7天天气 （第一个元素代表今天）
                            {
                              "type": 1,
                              "city": "上海",
                              "temperatureCurrent": 10,
                              "temperatureMax": 25,
                              "temperatureMin": 2
                            },
                            {
                              "type": 1,
                              "city": "上海",
                              "temperatureCurrent": 5,
                              "temperatureMax": 25,
                              "temperatureMin": 2
                            },
                            {
                              "type": 1,
                              "city": "上海",
                              "temperatureCurrent": 5,
                              "temperatureMax": 25,
                              "temperatureMin": 2
                            },
                            {
                              "type": 1,
                              "city": "上海",
                              "temperatureCurrent": 5,
                              "temperatureMax": 25,
                              "temperatureMin": 2
                            },
                            {
                              "type": 1,
                              "city": "上海",
                              "temperatureCurrent": 5,
                              "temperatureMax": 25,
                              "temperatureMin": 2
                            },
                            {
                              "type": 1,
                              "city": "上海",
                              "temperatureCurrent": 5,
                              "temperatureMax": 25,
                              "temperatureMin": 2
                            },
                            {
                              "type": 1,
                              "city": "上海",
                              "temperatureCurrent": 5,
                              "temperatureMax": 25,
                              "temperatureMin": 2
                            },
                          ]
                        }
                      }
                    ]
                  };
                } else if (type == YJSDKClientType.setUTEAlarmArray_vibrate_) {
                  /// 设置闹钟
                  arguments = {
                    "list": [
                      // 第一个对象是model类型
                      {
                        YJSDKClientParameterType
                            .yjSDKClientParameterTypeArrayModel.name: {
                          YJSDKClientParameterUTEModelAlarm: [
                            //设置闹钟
                            //设置闹钟1
                            {
                              "time": "14:10",
                              "week": YJSDKUTEAlarmWeek
                                  .yjSDKUTEAlarmWeekMonday.value |
                              YJSDKUTEAlarmWeek
                                  .yjSDKUTEAlarmWeekTuesday.value |
                              YJSDKUTEAlarmWeek
                                  .yjSDKUTEAlarmWeekWednesday.value |
                              YJSDKUTEAlarmWeek
                                  .yjSDKUTEAlarmWeekThursday.value |
                              YJSDKUTEAlarmWeek
                                  .yjSDKUTEAlarmWeekFriday.value |
                              YJSDKUTEAlarmWeek
                                  .yjSDKUTEAlarmWeekSaturday.value |
                              YJSDKUTEAlarmWeek.yjSDKUTEAlarmWeekSunday.value,
                              "enable": true,
                              "num": 1,
                              "countVibrate": 5
                            },
                            //设置闹钟2
                            {
                              "time": "14:11",
                              "week": YJSDKUTEAlarmWeek
                                  .yjSDKUTEAlarmWeekMonday.value |
                              YJSDKUTEAlarmWeek
                                  .yjSDKUTEAlarmWeekTuesday.value |
                              YJSDKUTEAlarmWeek
                                  .yjSDKUTEAlarmWeekWednesday.value |
                              YJSDKUTEAlarmWeek
                                  .yjSDKUTEAlarmWeekThursday.value |
                              YJSDKUTEAlarmWeek
                                  .yjSDKUTEAlarmWeekFriday.value |
                              YJSDKUTEAlarmWeek
                                  .yjSDKUTEAlarmWeekSaturday.value |
                              YJSDKUTEAlarmWeek.yjSDKUTEAlarmWeekSunday.value,
                              "enable": true,
                              "num": 2,
                              "countVibrate": 5
                            },
                            //设置闹钟3
                            {
                              "time": "14:12",
                              "week": YJSDKUTEAlarmWeek
                                  .yjSDKUTEAlarmWeekMonday.value |
                              YJSDKUTEAlarmWeek
                                  .yjSDKUTEAlarmWeekTuesday.value |
                              YJSDKUTEAlarmWeek
                                  .yjSDKUTEAlarmWeekWednesday.value |
                              YJSDKUTEAlarmWeek
                                  .yjSDKUTEAlarmWeekThursday.value |
                              YJSDKUTEAlarmWeek
                                  .yjSDKUTEAlarmWeekFriday.value |
                              YJSDKUTEAlarmWeek
                                  .yjSDKUTEAlarmWeekSaturday.value |
                              YJSDKUTEAlarmWeek.yjSDKUTEAlarmWeekSunday.value,
                              "enable": true,
                              "num": 3,
                              "countVibrate": 5
                            },
                          ]
                        }
                      },
                      // 第二个对象是int类型
                      {
                        "vibrate" : 8
                      }
                    ]
                  };
                } else if (type == YJSDKClientType.setUTEOption_) {
                  /// 设置部分设备信息
                  arguments = {
                    "list": [
                      // 第一个对象是枚举类型
                      {
                        "option": YJSDKUTEOption.yjUTEOptionOpen24HourHRM.index,/// 设置24小时心率开和关yjUTEOptionClose24HourHRM
                      }
                    ]
                  };
                } else if (type == YJSDKClientType.setBodyTemperatureAutoTestDuration_startTime_endTime_) {
                  /// 设置自动打开关闭体温
                  arguments = {
                    "list": [
                      // 第一个对象是枚举类型
                      {
                        "open": true,
                      },
                      {
                        "startTime": "08:30",
                      },
                      {
                        "endTime": "18:00",
                      },
                    ]
                  };
                } else if (type == YJSDKClientType.setBodyTemperatureAlarmOpen_max_alarmMin_) {
                  /// 设置体温报警
                  arguments = {
                    "list": [
                      // 第一个对象是枚举类型
                      {
                        "open": true,
                      },
                      {
                        "max": 36.1,
                      },
                      {
                        "min": 35.1,
                      },
                    ]
                  };
                }
                return InkWell(
                  onTap: () async {
                    var value = await YjHealthPlugin.instance.flutterSendEvent(
                        flutterActionModel: FlutterActionModel(
                            type: FlutterActionType.sendData,
                            params: {
                          "name": yjSDKClientTypeName,
                          "method": type.name,
                          "tag": type.index.toString(),
                          "arguments": arguments,
                        }));
                    if (value != null) {
                      print("(${type.name})命令执行完成有返回值");
                      print("得到的SDK client 返回值===");
                      print(value);
                      print("得到的SDK client 返回值===end");
                    } else {
                      print("(${type.name})命令执行完成");
                    }
                  },
                  child: ListTile(
                    title: Text(
                        "${type.name} ##arguments:${arguments.toString()} ##${type.index}"),
                  ),
                );
              }).toList(),
            ),
          ],
        ));
  }
}
